import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * @Author: WangYongGan
 * @Date: 2021/11/3 12:28
 * @Description:
 */
public class test {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        students.add(new Student(1, "aa"));
        students.add(new Student(1, "aa"));
        students.add(new Student(2, "aa"));
        students.add(new Student(1, "aa"));
        int i = 0;
        students.forEach(o -> {
            Date date = new Date();
            Random random = new Random();
            int sp = random.nextInt(100);
            try {
                Thread.sleep(sp);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("sleep:" + sp + "ms");
            date.setTime(date.getTime() + sp);
            Date date1 = new Date();
            if (date.before(date1))
                return;
            System.out.println("\tsuccess:" + o);
        });
    }
}

class Student {
    public int age;
    private String name;

    public Student(int age, String name) {
        this.age = age;
        this.name = name;
    }
}
